package com.sz.app.oss.api.logistics.base;

import com.sz.app.oss.constants.MessagesCodes;
import com.sz.app.oss.constants.Permissions;
import com.sz.biz.app.web.BaseController;
import com.sz.biz.logistics.constants.BaseConstants;
import com.sz.biz.logistics.constants.ListStatusQueryConstants;
import com.sz.biz.logistics.core.dto.*;
import com.sz.biz.logistics.core.entity.ProductRegionRel;
import com.sz.biz.logistics.core.entity.ProductServiceRel;
import com.sz.biz.logistics.base.service.AirportService;
import com.sz.biz.logistics.base.service.PortService;
import com.sz.biz.logistics.core.service.ProductCargoTypeRelService;
import com.sz.biz.logistics.core.service.ProductRegionRelService;
import com.sz.biz.logistics.core.service.ProductService;
import com.sz.biz.logistics.core.service.ProductServiceRelService;
import com.sz.common.base.dao.ParamData;
import com.sz.common.base.dto.QueryParams;
import com.sz.common.base.dto.ResultDto;
import com.sz.common.base.utils.StringUtils;
import com.sz.common.core.system.entity.SysDict;
import com.sz.common.core.system.service.SysDictService;
import com.sz.app.oss.api.logistics.base.dto.ApprovalAuditMsgDto;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Function: ProductController <br>
 * Author: zhengpenghui <br>
 * Date: 2017-04-26 16:30:00
 */
@RestController
@RequestMapping("${api}/biz/product")
@Api(description = " ", tags = "035、产品管理")
public class ProductController extends BaseController {

    @Autowired
    private ProductService productService;

    @Autowired
    private ProductServiceRelService productServiceRelService;

    @Autowired
    private ProductRegionRelService productRegionRelService;

    @Autowired
    private ProductCargoTypeRelService productCargoTypeRelService;

    @Autowired
    SysDictService sysDictService;
    
    @Autowired
    private AirportService airportService;
    @Autowired
    private PortService portService;


    /**
     * 根据产品id查询产品组信息
     */
    @ApiOperation(value = "根据产品id查询产品组信息", notes = "根据产品id查询产品组信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", required = true, dataType = "Integer", paramType = "path")})
    @RequestMapping(value = "/group/{id}", method = {RequestMethod.GET})
    public ResultDto getProductGroupById(@PathVariable Integer id) {
        ProductGroupInfo productGroup = productService.getProductGroupById(id);
        ResultDto dto = new ResultDto();
        dto.setData(productGroup);
        return dto;
    }

    /**
     * 产品组信息、产品可选服务信息
     */
    @ApiOperation(value = "产品组信息、产品可选服务信息", notes = "产品组信息、产品可选服务信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", required = true, dataType = "Integer", paramType = "path")})
    @RequestMapping(value = "/serviceInfos/{id}", method = {RequestMethod.GET})
    public ResultDto getProductServiceInfos(@PathVariable Integer id) {
        ProductGroupOptServiceInfo productGroupOptServiceInfo = productService.getProductServiceInfos(id);
        ResultDto dto = new ResultDto();
        dto.setData(productGroupOptServiceInfo);
        return dto;
    }

    /**
     * 新建产品基本信息
     *
     * @throws Exception
     */
    @ApiOperation(value = "新建产品", notes = "新建产品<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({@ApiImplicitParam(name = "productDto", value = "提交产品信息\r\n "
            + "name,estimatedTime,estimatedUnit,code, \r\nweightLimitMin, weightLimitMax, weightLimitUnitCode\r\nintroduction,productGroupLeafId,remarks, image, acceptType(受理方式：0: 自动； 1：人工),isPublic(true: 公开， false： 不公开)", required = true, dataType = "ProductDto", paramType = "body")})
    @RequestMapping(value = "", method = {RequestMethod.POST})
    @RequiresPermissions(Permissions.BIZ_MGT_BASE_PRODUCT)
    public ResultDto saveProduct(@RequestBody ProductDto productDto) throws ParseException {
        ProductDto productInfo = productService.save(productDto);
        ResultDto result = this.getSaveSuccessDto(MessagesCodes.MODULE_PRODUCT);
        ParamData productMap = new ParamData();
        productMap.put("id", productInfo.getId());
        productMap.put("uid", productInfo.getUid());
        result.setData(productMap);
        return result;
    }

    /**
     * 根据产品id查询产品范围
     */
    @ApiOperation(value = "查询产品货物类型", notes = "查询产品货物类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", required = true, dataType = "Integer", paramType = "path")})
    @RequestMapping(value = "/cargo/{id}", method = {RequestMethod.GET})
    public ResultDto getCargoByProductId(@PathVariable Integer id) {
        List<ProductCargotypeRelDto> cargoTypeList = productCargoTypeRelService.findByProductId(id);
        ResultDto dto = new ResultDto();
        dto.setData(cargoTypeList);
        return dto;
    }

    /**
     * 修改产品基本信息
     *
     * @throws Exception
     */
    @ApiOperation(value = "修改产品", notes = "修改产品<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "修改产品的uid ", required = true, dataType = "String", paramType = "path"),
            @ApiImplicitParam(name = "productDto", value = "提交产品信息\r\n "
                    + "name,estimatedTime,estimatedUnit,code, \r\nweightLimitMin, weightLimitMax, weightLimitUnitCode,\r\nintroduction,productGroupLeafId,remarks, image, acceptType(受理方式：0: 自动； 1：人工),isPublic(true: 公开， false： 不公开)", required = true, dataType = "ProductDto", paramType = "body")})
    @RequestMapping(value = "/{uid}", method = {RequestMethod.PUT})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto updateProduct(@PathVariable String uid, @RequestBody ProductDto productDto) throws ParseException {
        productDto.setUid(uid);
        ProductDto productInfo = productService.update(uid, productDto);
        ResultDto dto = this.getUpdateSuccessDto(MessagesCodes.MODULE_PRODUCT);
        ParamData productMap = new ParamData();
        productMap.put("id", productInfo.getId());
        productMap.put("uid", productInfo.getUid());
        dto.setData(productMap);
        return dto;
    }

    /**
     * 产品计重规则取值方式
     */
    @ApiOperation(value = "产品计重规则取值方式", notes = "产品计重规则取值方式")
    @ApiImplicitParams({})
    @RequestMapping(value = "/weight/valueType", method = {RequestMethod.GET})
    public ResultDto weightValueType() {
        List<SysDict> weightValueType = sysDictService.findByCatalog("biz.product.weight.value.type");
        ResultDto dto = new ResultDto();
        dto.setData(weightValueType);
        return dto;
    }

    /**
     * 产品服务属性获取
     */
    @ApiOperation(value = "产品服务属性获取", notes = "产品服务属性获取")
    @ApiImplicitParams({})
    @RequestMapping(value = "/services/property", method = {RequestMethod.GET})
    public ResultDto serviceProperty() {
        List<SysDict> weightValueType = sysDictService.findByCatalog("biz.product.serives.property");
        ResultDto dto = new ResultDto();
        dto.setData(weightValueType);
        return dto;
    }

    /**
     * 产品预估时效单位
     */
    @ApiOperation(value = "产品预估时效单位", notes = "产品预估时效单位")
    @ApiImplicitParams({})
    @RequestMapping(value = "/services/estimated", method = {RequestMethod.GET})
    public ResultDto serviceEstimatedUnit() {
        List<SysDict> estimatedList = sysDictService.findByCatalog("biz.product.estimated.unit");
        ResultDto dto = new ResultDto();
        dto.setData(estimatedList);
        return dto;
    }

    /**
     * 产品计重规则维护
     *
     * @throws Exception
     */
    @ApiOperation(value = "修改产品计重信息", notes = "修改产品计重信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "修改产品的uid ", required = true, dataType = "String", paramType = "path"),
            @ApiImplicitParam(name = "productDto", value = "提交产品计重信息\r\n "
                    + "isVolume, volumeFactor, weightValueTye", required = true, dataType = "ProductDto", paramType = "body")})
    @RequestMapping(value = "/{uid}/weight", method = {RequestMethod.PUT})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto updateProductWeightType(@PathVariable String uid, @RequestBody ProductDto productDto) throws ParseException {
        productDto.setUid(uid);
        productService.updateWeightInfo(uid, productDto);
        ResultDto dto = this.getUpdateSuccessDto(MessagesCodes.MODULE_PRODUCT_WEIGHT);
        dto.setData(uid);
        return dto;
    }

    /**
     * 产品服务添加
     *
     * @throws Exception
     */
    @ApiOperation(value = "添加产品服务信息", notes = "添加产品服务信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @RequestMapping(value = "/services", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto addProductServices(@RequestBody @ApiParam(value = "产品服务信息", required = true) @Validated ProductServiceRelDto productServiceRelDto) throws ParseException {
        Integer id = productServiceRelService.save(productServiceRelDto);
        ResultDto dto = this.getSaveSuccessDto(MessagesCodes.MODULE_PRODUCT_SERVICES);
        dto.setData(id);
        return dto;
    }

    /**
     * 产品服务删除(根据服务属性删除)
     *
     * @throws Exception
     */
    @ApiOperation(value = "产品服务删除(根据服务属性删除)", notes = "产品服务删除(根据服务属性删除)<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @RequestMapping(value = "/services/deletions", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto deleteProductServices(@RequestBody @ApiParam(value = "要删除的产品服务", required = true) @Validated ProductServiceRelDeleteDto productServiceRelDeleteDto) throws ParseException {
        productServiceRelService.delete(productServiceRelDeleteDto, false);
        ResultDto dto = this.getDeleteSuccessDto(MessagesCodes.MODULE_PRODUCT_SERVICES);
        return dto;
    }

    /**
     * 产品服务删除
     *
     * @throws Exception
     */
    @ApiOperation(value = "删除产品服务信息", notes = "删除产品服务信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "psIds", value = "产品服务关联id", required = true, dataType = "List", paramType = "body")
    })
    @RequestMapping(value = "/services/delete", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto deleteServices(@RequestBody List<Integer> psIds) throws ParseException {
        productServiceRelService.deleteByPsIds(psIds);
        ResultDto dto = this.getDeleteSuccessDto(MessagesCodes.MODULE_PRODUCT_SERVICES);
        return dto;
    }

    /**
     * 产品服务维护
     *
     * @throws Exception
     */
    @ApiOperation(value = "修改产品服务信息", notes = "修改产品服务信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT + "-" + Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL)
    @RequestMapping(value = "/{id}/services", method = {RequestMethod.PUT})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto updateProductServices( @RequestBody @ApiParam(value = "产品服务信息", required = true) @Validated ProductServiceRelDto productServiceRelDto) throws ParseException {
        productServiceRelService.update(productServiceRelDto);
        return this.getUpdateSuccessDto(MessagesCodes.MODULE_PRODUCT_SERVICES);
    }

    /**
     * 同一种类型的服务在统一产品下只能有一个
     */
    @ApiOperation(value = "同一种类型的服务在统一产品下只能有一个", notes = "同一种类型的服务在统一产品下只能有一个")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productId", value = "产品id", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "serviceTypeCode", value = "服务类型编码", required = true, dataType = "string", paramType = "query")})
    @RequestMapping(value = "/checkserviceType", method = {RequestMethod.GET})
    public ResultDto checkServiceTypeInProduct(@RequestParam Integer productId, @RequestParam String serviceTypeCode) {
        productServiceRelService.checkServiceTypeInProduct(productId, serviceTypeCode);
        return new ResultDto();
    }

    /**
     * 获取排除产品已有服务类型的其他服务类型
     * @param productId
     * @return
     */
    @ApiOperation(value = "获取排除产品已有服务类型的其他服务类型", notes = "获取排除产品已有服务类型的其他服务类型")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productId", value = "产品id", required = true, dataType = "int", paramType = "path")})
    @RequestMapping(value = "/servicetypes/{productId}", method = {RequestMethod.GET})
    public ResultDto findServiceTypes(@PathVariable Integer productId) {
        List<SysDict> dictList = productService.findServiceTypesExcludePrd(productId);
        ResultDto dto = new ResultDto();
        dto.setData(dictList);
        return dto;
    }

    /**
     * 异步校验产品范围编码
     *
     * @param code
     * @return
     */
    @ApiOperation(value = "异步校验产品范围编码", notes = "异步校验产品范围编码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "范围id", required = false, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "code", value = "范围编码", required = true, dataType = "string", paramType = "query")
    })
    @RequestMapping(value = "/region/code", method = RequestMethod.GET)
    public ResultDto checkProductRegionCode(@RequestParam(required = false) Integer id, @RequestParam String code) {
        productRegionRelService.checkProductRegionCode(id, code);
        return new ResultDto();
    }

    /**
     * 产品范围添加
     *
     * @throws Exception
     */
    @ApiOperation(value = "添加产品范围信息", notes = "添加产品范围信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT + " " + Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL)
    @RequestMapping(value = "/region", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto addProductRegion(@ApiParam(value = "添加产品范围信：productId, type(取值：s/e), remark", required = true) @RequestBody ProductRegionRelDto productRegionRelDto) throws ParseException {
        String uid = productRegionRelService.save(productRegionRelDto);
        ResultDto dto = this.getSaveSuccessDto(MessagesCodes.MODULE_PRODUCT_REGION);
        dto.setData(uid);
        return dto;
    }

    /**
     * 产品范围维护
     *
     * @throws Exception
     */
    @ApiOperation(value = "修改产品范围信息", notes = "修改产品范围信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品范围的id ", required = true, dataType = "Integer", paramType = "path"),
            @ApiImplicitParam(name = "productRegionRelDto", value = "提交产品范围信息\r\n "
                    + "productId, type(取值：s/e), remark", required = true, dataType = "ProductRegionRelDto", paramType = "body")})
    @RequestMapping(value = "/{id}/region", method = {RequestMethod.PUT})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto updateProductRegion(@PathVariable Integer id, @RequestBody ProductRegionRelDto productRegionRelDto) throws ParseException {
        productRegionRelDto.setId(id);
        String newUid = productRegionRelService.update(productRegionRelDto);
        ResultDto dto = this.getUpdateSuccessDto(MessagesCodes.MODULE_PRODUCT_REGION);
        dto.setData(newUid);
        return dto;
    }

    /**
     * 产品范围删除
     *
     * @throws Exception
     */
    @ApiOperation(value = "删除产品范围信息", notes = "删除产品范围信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "产品范围关联的id ", required = true, dataType = "List", paramType = "body")})
    @RequestMapping(value = "/region/deletions", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto deleteProductRegion(@RequestBody List<Integer> ids) throws ParseException {
        productRegionRelService.batchDeleteById(ids);
        return this.getDeleteSuccessDto(MessagesCodes.MODULE_PRODUCT_REGION);
    }

    /**
     * 根据uids删除产
     *
     * @throws Exception
     */
    @ApiOperation(value = "删除产品", notes = "删除产品<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uids", value = "uids", required = true, dataType = "List", paramType = "body")})
    @RequestMapping(value = "/deletions", method = {RequestMethod.POST})
    @RequiresPermissions(Permissions.BIZ_MGT_BASE_PRODUCT)
    public ResultDto deleteProduct(@RequestBody List<String> uids) {
        productService.batchdelete(uids);
        return getDeleteSuccessDto(MessagesCodes.MODULE_PRODUCT);
    }

    /**
     * 根据产品id查询产品
     */
    @ApiOperation(value = "查询产品", notes = "查询产品<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", required = true, dataType = "Integer", paramType = "path")})
    @RequestMapping(value = "/{id}", method = {RequestMethod.GET})
    public ResultDto getProductById(@PathVariable Integer id) {
        ProductDto productDto = productService.findById(id);
        ResultDto dto = new ResultDto();
        dto.setData(productDto);
        return dto;
    }

    /**
     * 根据产品uid查询产品
     */
    @ApiOperation(value = "根据产品uid查询产品", notes = "根据产品uid查询产品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品的uid ", required = true, dataType = "String", paramType = "path")})
    @RequestMapping(value = "/search/{uid}", method = {RequestMethod.GET})
    public ResultDto getProductByUid(@PathVariable String uid) {
        ProductDto productDto = productService.findByUid(uid);
        ResultDto dto = new ResultDto();
        dto.setData(productDto);
        return dto;
    }


    /**
     * 订单产品列表初始化
     */
    //TODO 影响到的API
    @ApiOperation(value = "订单产品列表初始化", notes = "订单产品列表初始化")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "customerId", value = "客户id", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000", dataType = "int", paramType = "query")})
    @RequestMapping(value = "/list/order", method = {RequestMethod.GET})
    public ResultDto findProductListForOrder(@RequestParam(required = false) String q,
                                             @RequestParam(required = false, defaultValue = "-1") int customerId,
                                             @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                             @RequestParam(required = false, defaultValue = "10") int pageSize) {
        q = StringUtils.replaceSqlPattern(q);
        QueryParams params = new QueryParams(pageSize, pageIndex, q, null);
        params.put("q", q);
        params.put("customerId", customerId);
        return productService.findByFilterForOrder(params);
    }

    /**
     * 产品列表初始化，返回产品id, uid,名称, code
     */
    @ApiOperation(value = "产品列表初始化，返回产品id, uid,名称", notes = "产品列表初始化，返回产品id, uid,名称")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "groupId", value = "产品组id", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "isForCalculate", value = "是否为价格试算（速递包含除了空运和海运产品）", dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000", dataType = "int", paramType = "query")})
    @RequestMapping(value = "/list/short", method = {RequestMethod.GET})
    public ResultDto findProductListWithUidName(@RequestParam(required = false) String q,
                                                @RequestParam(required = false) Integer groupId,
                                                @RequestParam(required = false, defaultValue = "false") Boolean isForCalculate,
                                                @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                                @RequestParam(required = false, defaultValue = "10") int pageSize) {
        q = StringUtils.replaceSqlPattern(q);
        QueryParams params = new QueryParams(pageSize, pageIndex, q, null);
        params.put("q", q);
        params.put("groupId", groupId);
        params.put("isForCalculate", isForCalculate);
        return productService.findProductListReturnUidName(params);
    }

    /**
     * 产品列表初始化，返回产品id, uid,没有分页
     */
    @ApiOperation(value = "产品列表初始化，返回产品id, uid,没有分页", notes = "产品列表初始化，返回产品id, uid,没有分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "groupId", value = "产品组id", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000", dataType = "int", paramType = "query")})
    @RequestMapping(value = "/list/short/all", method = {RequestMethod.GET})
    public ResultDto findProductListWithUidNameAll(@RequestParam(required = false) String q,
                                                   @RequestParam(required = false, defaultValue = "1") int groupId,
                                                   @RequestParam(required = false, defaultValue = "1") int pageIndex,
                                                   @RequestParam(required = false, defaultValue = "10") int pageSize) {
        q = StringUtils.replaceSqlPattern(q);
        QueryParams params = new QueryParams(pageSize, pageIndex, q, null);
        params.put("q", q);
        params.put("groupId", groupId);
        List<Map<String, Object>> products = productService.findProductListReturnUidNameAll(params);
        ResultDto dto = new ResultDto();
        dto.setData(products);
        return dto;
    }

    /**
     * 分页查询产品
     */
    @ApiOperation(value = "搜索产品", notes = "搜索产品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态：-1全部(默认) -2审核列表的全部 1草稿 2提交审核 3审核通过 4已启用 5已停用", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "includeAllAudit", value = "仅当status为3时，是否包含审核以上的状态", dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "cargoType", value = "货物类型", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "topGrade", value = "产品组", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "secondGrade", value = "产品组2级", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "orderby", value = "排序字段:草稿列表createtime(默认) 待审核列表submittime",
                    dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "sort", value = "排序的字段", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "asc", value = "排序方式", dataType = "boolean", paramType = "query", defaultValue = "true")})
    @RequestMapping(value = "/list", method = {RequestMethod.GET})
    public ResultDto findProductList(@RequestParam(required = false) String q,
                                     @RequestParam(required = false, defaultValue = "-1") int status,
                                     @RequestParam(required = false, defaultValue = "false") boolean includeAllAudit,
                                     @RequestParam(required = false, defaultValue = "-1") int cargoType,
                                     @RequestParam(required = false, defaultValue = "-1") int topGrade,
                                     @RequestParam(required = false, defaultValue = "-1") int secondGrade,
                                     @RequestParam(required = false, defaultValue = "createtime") String orderby,
                                     @RequestParam int pageIndex,
                                     @RequestParam int pageSize,
                                     @RequestParam(required = false) String sort,
                                     @RequestParam(required = false, defaultValue = "true") Boolean asc) {
        q = StringUtils.replaceSqlPattern(q);
        QueryParams params = new QueryParams(pageSize, pageIndex, q, sort, asc);
        int realIsOnline = -1;
        int realStatus = -1;
        if (status == ListStatusQueryConstants.Status.ALL) {
            realIsOnline = -1;
            realStatus = -1;
        }
        if (status == ListStatusQueryConstants.Status.AUDIT_ALL) {
            realIsOnline = -1;
            realStatus = 3;
        }
        if (status == ListStatusQueryConstants.Status.DRAFTS ||
                status == ListStatusQueryConstants.Status.PENDING_AUDIT ||
                status == ListStatusQueryConstants.Status.AUDIT_PASS) {
            realIsOnline = -2;
            realStatus = status;
        }
        if (status == ListStatusQueryConstants.Status.ENABLED) {
            realStatus = 3;
            realIsOnline = 1;
        }
        if (status == ListStatusQueryConstants.Status.DISABLE) {
            realStatus = 3;
            realIsOnline = 0;
        }
        if (status == ListStatusQueryConstants.Status.AUDIT_PASS && includeAllAudit) {
            realIsOnline = -1;
        }
        params.put("isOnline", realIsOnline);
        params.put("status", realStatus);
        params.put("cargoType", cargoType);
        params.put("topGrade", topGrade);
        params.put("secondGrade", secondGrade);
        params.put("orderby", orderby);
        params.put("asc", asc);
        return productService.findByFilter(params);
    }

    /**
     * 产品上线
     */
    @ApiOperation(value = "产品上线", notes = "产品上线-<br>" + Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品uid", dataType = "String", paramType = "path", required = true)
    })
    @RequestMapping(value = "/{uid}/online", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL})
    public ResultDto online(@PathVariable String uid) throws ParseException {
        productService.online(uid);
        return getOnlineSuccessDto();
    }

    /**
     * 产品下线
     */
    @ApiOperation(value = "产品下线", notes = "产品下线-<br>" + Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品uid", dataType = "String", paramType = "path", required = true)
    })
    @RequestMapping(value = "/{uid}/offline", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL})
    public ResultDto offline(@PathVariable String uid) throws ParseException {
        Integer newId = productService.offline(uid);
        ResultDto resultDto = getOfflineSuccessDto();
        resultDto.setData(newId);
        return resultDto;
    }

    /**
     * 审核产品
     */
    @ApiOperation(value = "审核产品", notes = "审核产品-<br>" + Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品uid", dataType = "String", paramType = "path", required = true),
            @ApiImplicitParam(name = "msg", value = "审核意见", dataType = "ApprovalAuditMsgDto",
                    paramType = "body", required = true)
    })
    @RequestMapping(value = "audit/{uid}", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL})
    public ResultDto updateStatus(@PathVariable String uid, @RequestBody ApprovalAuditMsgDto msg) throws ParseException {
        productService.audit(uid, msg.getMsg());
        return getAuditSuccessDto(MessagesCodes.MODULE_PRODUCT);
    }

    /**
     * 产品打回
     */
    @ApiOperation(value = "打回产品", notes = "打回产品-<br>" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品uid", dataType = "String", paramType = "path", required = true),
            @ApiImplicitParam(name = "msg", value = "审核意见", dataType = "ApprovalAuditMsgDto",
                    paramType = "body", required = true)
    })
    @RequestMapping(value = "rejections/{uid}", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL})
    public ResultDto reject(@PathVariable String uid, @RequestBody ApprovalAuditMsgDto msg) {
        productService.reject(uid, msg.getMsg());
        return getRejectSuccessDto();
    }

    /**
     * 产品提交
     */
    @ApiOperation(value = "提交产品", notes = "-<br>" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uids", value = "产品uid", dataType = "String[]", paramType = "body", required = true)
    })
    @RequestMapping(value = "/submit", method = {RequestMethod.POST})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT})
    public ResultDto submit(@RequestBody List<String> uids) throws ParseException {
        productService.submit(uids);
        return getSubmitSuccessDto(MessagesCodes.MODULE_PRODUCT);
    }

    /**
     * 异步校验产品编码
     */
    @ApiOperation(value = "异步校验产品编码", notes = "异步校验产品编码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "产品编码", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "uid", value = "名称uid", dataType = "string", paramType = "query")})
    @RequestMapping(value = "/checkCode", method = {RequestMethod.GET})
    public ResultDto codeCheck(@RequestParam(required = true) String code, @RequestParam(required = false) String uid) {
        productService.codeCheck(uid, code);
        return new ResultDto();
    }

    /**
     * 异步校验产品名称
     */
    @ApiOperation(value = "异步校验产品名称", notes = "异步校验产品名称")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "产品名称", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "uid", value = "名称uid 修改时传uid 新增时传空",
                    dataType = "string", paramType = "query")})
    @RequestMapping(value = "/checkname", method = {RequestMethod.GET})
    public ResultDto supplierNameCheck(@RequestParam String name, @RequestParam(required = false, defaultValue = "0") String uid) {
        productService.nameCheck(uid, name);
        return new ResultDto();
    }

    /**
     * 异步校验服务是否已经在产品中存在
     */
    @ApiOperation(value = "异步校验服务是否已经在产品中存在", notes = "异步校验服务是否已经在产品中存在")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productId", value = "产品id", required = true, dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "serviceUid", value = "服务uid", required = true, dataType = "string", paramType = "query")})
    @RequestMapping(value = "/checkservices", method = {RequestMethod.GET})
    public ResultDto checkServiceInProduct(@RequestParam Integer productId, @RequestParam String serviceUid) {
        productServiceRelService.checkServiceIsExistInProduct(productId, serviceUid);
        return new ResultDto();
    }


    /**
     * 按类型取产品的服务
     */
    @ApiOperation(value = "按类型取产品的服务", notes = "按类型取产品的服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品的uid", dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "type", value = " all：全部服务 main:主服务 required:必选服务 optional:可选服务",
                    dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "hasDisabled", value = "是否包含已停用服务,默认为false", dataType = "boolean", paramType = "query"),
    })
    @RequestMapping(value = "/{uid}/services/{type}", method = {RequestMethod.GET})
    public ResultDto findProductServices(@PathVariable String uid, @PathVariable String type,
                                         @RequestParam(required = false, defaultValue = "false") boolean hasDisabled) {
        String code = "all".equals(type) ? "ALL" : type.toUpperCase();
        List<ProductServiceRel> dtos = productService.findProductServices(uid, code, null, hasDisabled, true);
        ResultDto dto = new ResultDto();
        dto.setData(dtos);
        return dto;
    }

    /**
     * 根据产品获取产品下所有的服务类型
     */
    @ApiOperation(value = "按类型取产品的服务", notes = "按类型取产品的服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品的uid", dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "type", value = " all：全部服务 main:主服务 required:必选服务 optional:可选服务",
                    dataType = "string", paramType = "path"),
    })
    @RequestMapping(value = "/{uid}/servicetypes/{type}", method = {RequestMethod.GET})
    public ResultDto findProductServiceTypes(@PathVariable String uid, @PathVariable String type) {
        String code = "all".equals(type) ? "ALL" : type.toUpperCase();
        List<ProductServiceTypeDto> dtos = productService.findProductServiceTypes(uid, code);
        ResultDto dto = new ResultDto();
        dto.setData(dtos);
        return dto;
    }



    /**
     * 按类型取产品的服务
     */
    @ApiOperation(value = "按类型取产品的服务", notes = "按类型取产品的服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品的uid", dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "type", value = "main:主服务 required:必选服务 optional:可选服务", dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "ordinal", value = "节点", dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "hasDisabled", value = "是否包含已停用服务,默认为false", dataType = "boolean", paramType = "query"),
    })
    @RequestMapping(value = "/{uid}/services/region/{type}/{ordinal}", method = {RequestMethod.GET})
    public ResultDto findProductServiceRegions(@PathVariable String uid, @PathVariable String type, @PathVariable Integer ordinal,
                                         @RequestParam(required = false, defaultValue = "false") boolean hasDisabled) {
        String code = type.toUpperCase();
        ProductServiceRelDto dtos = productService.findProductServiceRegions(uid, code, ordinal, hasDisabled);
        ResultDto dto = new ResultDto();
        dto.setData(dtos);
        return dto;
    }

    /**
     * 分页查询产品下的服务
     */
    @ApiOperation(value = "根据产品id获取产品的服务信息", notes = "根据产品id获取产品的服务信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT + ", " + Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品id", dataType = "Integer", paramType = "query")
    })
    @RequestMapping(value = "/services", method = {RequestMethod.GET})
    @RequiresPermissions(value = {Permissions.BIZ_MGT_BASE_PRODUCT, Permissions.BIZ_MGT_BASE_PRODUCT_APPROVAL}, logical = Logical.OR)
    public ResultDto findServicesById(@RequestParam(required = true) Integer id) {
        List<Map> services = productService.findServicesById(id);
        ResultDto resultDto = new ResultDto();
        resultDto.setData(services);
        return resultDto;
    }

    /**
     * 根据客户id校验客户的地址列表当前产品是否支持
     */
    @ApiOperation(value = "根据客户id校验客户的地址列表当前产品是否支持", notes = "-")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品uid", dataType = "string", paramType = "path"),
            @ApiImplicitParam(name = "customerId", value = "客户id", dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "transportType", value = "地址类型", dataType = "int", paramType = "path")
    })
    @RequestMapping(value = "/{uid}/checkcustomer/{customerId}/{transportType}", method = {RequestMethod.GET})
    public ResultDto checkRegionByCustomerId(@PathVariable String uid,
                                             @PathVariable int customerId, @PathVariable int transportType) {
        return productService.checkRegionByCustomerId(uid, customerId, transportType);
    }

    /**
     * 根据重量以及产品UID校验当前产品是否支持
     */
    @ApiOperation(value = "根据重量以及产品UID校验当前产品是否支持", notes = "-")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品uid", dataType = "string", paramType = "path")
    })
    @RequestMapping(value = "/{uid}/checkweight", method = {RequestMethod.POST})
    public ResultDto checkWeight(@PathVariable String uid,
                                 @RequestBody @ApiParam(value = "重量对象", required = true) WeightDto weightDto) {
        return productService.checkWeight(uid, weightDto);
    }

    /**
     * 根据产品id查询产品范围
     */
    @ApiOperation(value = "查询产品范围", notes = "查询产品范围<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", required = true, dataType = "Integer", paramType = "path")})
    @RequestMapping(value = "/productregion/{id}", method = {RequestMethod.GET})
    public ResultDto getRegionByProductId(@PathVariable Integer id) {
        List<ProductRegionRel> regionList = productService.getRegionByProductId(id);
        ResultDto dto = new ResultDto();
        dto.setData(regionList);
        return dto;
    }

    /**
     * 根据产品id查询产品计重规则
     */
    @ApiOperation(value = "查询产品计重规则", notes = "查询产品计重规则<br>")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", required = true, dataType = "int", paramType = "path")})
    @RequestMapping(value = "/weight/{id}", method = {RequestMethod.GET})
    public ResultDto getWeightByProductId(@PathVariable Integer id) {
        return productService.getWeightByProductId(id);
    }

    /**
     * 判断是否有主服务
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "判断是否有主服务", notes = "判断是否有主服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品id", required = false, dataType = "Integer", paramType = "query")
    })
    @RequestMapping(value = "/ismainservice", method = RequestMethod.GET)
    public ResultDto checkProductRegionCode(@RequestParam(required = false) Integer id) {
        ResultDto dto = new ResultDto();
        Boolean isMainExist = productService.checkMainService(id);
        dto.setData(isMainExist);
        return dto;
    }

    /**
     * 查询产品的揽收服务
     *
     * @param uid uid
     * @return ResultDto
     */
    @ApiOperation(value = "查询产品的揽收服务", notes = "查询产品的揽收服务")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "uid", value = "产品uid", required = true, dataType = "string", paramType = "query")
    })
    @RequestMapping(value = "/receiveservices", method = RequestMethod.GET)
    public ResultDto getProductReceiveInfo(@RequestParam String uid) {
        ProductReceiveInfoDto productReceiveInfoDto = productService.findProductReceiveInfoByUid(uid);
        ResultDto dto = new ResultDto();
        dto.setData(productReceiveInfoDto);
        return dto;
    }

    /**
     * 根据产品id和type查询国家在产品的范围
     */
    @ApiOperation(value = "查询产品范围国家信息", notes = "查询产品范围国家信息<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "from:起点(s) to:目的地(e) 揽收地址(l)", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000",  dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/country", method = {RequestMethod.GET})
    public ResultDto getCountryByProductIdAndType(@RequestParam(required = true) Integer id,
    		@RequestParam(required = true) String type,
    		@RequestParam(required = false) String q,
    		@RequestParam(required = false, defaultValue = "1") int pageIndex,
            @RequestParam(required = false, defaultValue = "10") int pageSize) {
    	q = StringUtils.replaceSqlPattern(q);
        ResultDto dto = productService.getCountryByProductIdAndType(id, type,q,pageIndex,pageSize);
        return dto;
    }

    /**
     * 根据产品id,type和countryCode查询机场或港口
     */
    @ApiOperation(value = "查询产品范围内机场或港口", notes = "查询产品范围内机场或港口<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "countryCode", value = "国家编码", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "cityId", value = "城市id", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "from:起点(s) to:目的地(e)", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页",  dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000",  dataType = "int", paramType = "query")
    })
    @RequestMapping(value = "/transport", method = {RequestMethod.GET})
    public ResultDto getTransportByProductIdAndType(@RequestParam(required = true) Integer id,
    		@RequestParam(required = true) String countryCode,
    		@RequestParam(required = false) String cityId,
    		@RequestParam(required = true) String type,
    		@RequestParam(required = false) String q,
    		@RequestParam(required = false, defaultValue = "1") int pageIndex,
            @RequestParam(required = false, defaultValue = "10") int pageSize) {
    	q = StringUtils.replaceSqlPattern(q);
        ResultDto dto = productService.getTransportByProductIdAndType(id, countryCode,cityId, type, q,pageIndex,pageSize);
        return dto;
    }

    /**
     * 根据产品id,type,countryCode和parentId查询地区
     */
    @ApiOperation(value = "查询地区", notes = "查询地区<br>权限：" + Permissions.BIZ_MGT_BASE_PRODUCT)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "产品的id ", dataType = "Integer", paramType = "query"),
            @ApiImplicitParam(name = "countryCode", value = "国家编码", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "parentId", value = "父节点id", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "from:起点(s) to:目的地(e) 揽收地址(l)", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页",  dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000",  dataType = "int", paramType = "query")
            })
    @RequestMapping(value = "/area", method = {RequestMethod.GET})
    public ResultDto getAreaByProductIdAndType(@RequestParam(required = true) Integer id,
    		@RequestParam(required = true) String countryCode,
    		@RequestParam(required = false) String parentId,
    		@RequestParam(required = true) String type,
    		@RequestParam(required = false) String q,
    		@RequestParam(required = false, defaultValue = "1") int pageIndex,
            @RequestParam(required = false, defaultValue = "10") int pageSize) {
    	q = StringUtils.replaceSqlPattern(q);
        ResultDto dto = productService.getAreaByProductIdAndType(id, countryCode,parentId,type,q,pageIndex,pageSize);
        return dto;
    }
    
    /**
     * 分页查询机场或港口
     *
     * @throws Exception
     */
    @ApiOperation(value = "查询机场或港口", notes = "查询机场或港口<br>权限：")
    @ApiImplicitParams({
    	    @ApiImplicitParam(name = "countryId", value = "国家必填项，这样才能区分到后台去查地区那张表", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "cityId", value = "城市", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "q", value = "查询的关键字", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "类型：1为港口，6为机场", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "pageIndex", value = "分页", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小，max2000", required = true, dataType = "int", paramType = "query")
           })
    @RequestMapping(value = "/transportlist", method = {RequestMethod.GET})
    public
    @ResponseBody
    ResultDto findTransportList(@RequestParam(required = false) String countryId,
            @RequestParam(required = false) String cityId,
            @RequestParam(required = false) String q,
            @RequestParam(required = true) String type,
    		@RequestParam(required = false, defaultValue = "0") int pageIndex, 
    		@RequestParam(required = false, defaultValue = "10") int pageSize) {
    	ResultDto dto =null;
    	q = StringUtils.replaceSqlPattern(q);
        Map<String, Object> map = new HashMap<>();
        map.put("countryId", countryId);
        map.put("cityId", cityId);
        if(BaseConstants.TransportType.AIR.equals(type)){
        	dto = airportService.airportDropListPage(new QueryParams(pageSize, pageIndex, q, null, false).put(map));
        }
        else if(BaseConstants.TransportType.PORT.equals(type)){
        	dto = portService.portDropListPage(new QueryParams(pageSize, pageIndex, q, null, false).put(map));
        }
        return dto;
    }
}
